<?php
	require_once("../conexion/conexion.php");
	require_once("../Mantenedores/cliente.php");
	$num = $_GET['num'];
	$prov = $_GET['prov'];

	$con = new Conexion();
	$con2 = $con->conexionBD("fpproduccion");
	$sql = "select
				ProvNombre,
				ANombre,
				date_format(FacNFecha,'%d/%m/%Y') as fecha,
				FacNCod,
				FacNImpEsp,
				FacNNeto,
				FacNIVA,
				FacNTotal
				
				from FacturaNormal fn
				inner join Proveedor p on
				fn.ProvRut=p.ProvRut
				inner join Area a on
				fn.ACod=a.ACod
				
				where FacNNum='".$num."'";
	$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$datos = mysql_fetch_array($res);
	
	$nombre = utf8_decode($datos[0]);
	$area = utf8_decode($datos[1]);
	
	//items
	$con = new Conexion();
	$con2 = $con->conexionBD("fpproduccion");
	$sql = "select
				ItemFacNCant,
				ItemFacNObs,
				ItemFacNUnit
				
				from ItemFacNormal ifn
				inner join FacturaNormal fn on
				ifn.FacNCod=fn.FacNCod
				
				where FacNNum='".$num."' and fn.FacNCod='".$datos[3]."'";
	$res2= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<script src="../include_js/jquery.js" type="text/javascript"></script>
<script src="../include_js/popcalendar.js" type="text/javascript"></script>
<style>
.texto
{
	font-size:14px;
	margin-left:8px;
	font:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
}
.borde
{
	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.bordeA {	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
</style>
<script>
function Cerrar()
{
	window.close();
}
</script>
</head>

<body>
<a name="arriba"></a>
<br class="end" />
<div id="area">
 <div id="navbar">
    	<div class="righty"></div>
        <div class="lefty"></div>
		<ul>
            <li><label style="font-size:12px;">N&deg; Factura "<?php echo $num;?>"</label></li>
		</ul>
 </div>
 <div id="content">
<form name="form_exp" id="form_exp" method="post">
<table width="100%" cellpadding="2" cellspacing="0" border="0" class="uno">
<tr>
  <td class="borde" colspan="3">&nbsp;</td>
  <td width="33%" class="borde">&nbsp;</td>
</tr>
<tr>
  <td width="19%" class="borde" style="text-align:right"><label class="texto">Fecha:</label></td>
  <td width="40%" class="borde"><label class="texto"><?php echo $datos[2]?></label></td>
  <td width="8%" class="borde" style="text-align:right"><label class="texto">Area:</label></td>
  <td class="borde"><label class="texto"><?php echo $area;?></label></td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Proveedor:</label></td>
  <td class="borde" colspan="2"><label class="texto"><?php echo $nombre;?></label></td>
  <td class="borde">&nbsp;</td>
</tr>

<tr>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde" colspan="3">&nbsp;</td>
</tr>
<tr>
  <td class="borde" colspan="4" style="text-align:center">
  <table border="0" cellpadding="0" cellspacing="0" width="80%">
  <thead>
  <tr>
  	<th width="15%">cantidad</th>
	<th width="48%">detalle</th>
	<th width="19%">v. unitario</th>
	<th width="18%">total</th>
  </tr>
  </thead>
  <?php
  while($reg = mysql_fetch_array($res2))
  {
  		$total = $reg[0]*$reg[2];
  		echo "<tr class='filaImpar'>";
		echo "<td width=\"13%\" style='text-align:center'>".$reg[0]."</td>";
		echo "<td width=\"27%\" style='text-align:lefth;padding-left:5px;'>".$reg[1]."</td>";
		echo "<td width=\"19%\" style='text-align:right;padding-right:15px;'>".number_format($reg[2],0,',','.')."</td>";
		echo "<td width=\"15%\" style='text-align:right;padding-right:15px;'>".number_format($total,0,',','.')."</td>";
		echo "</tr>";
  }
  ?>
  </table>  </td>
</tr>
<tr>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde" colspan="3">&nbsp;</td>
</tr>
<tr>
  <td class="borde" style="text-align:right;"><label class="texto">Imp.Especifico:</label></td>
  <td class="borde" colspan="3"><label class="texto"><?php echo number_format($datos[4],0,',','.')?></label></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;"><label class="texto">Total Neto $:</label></td>
  <td class="borde" colspan="3"><label class="texto"><?php echo number_format($datos[5],0,',','.')?></label></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;"><label class="texto">I.V.A $:</label></td>
  <td class="borde" colspan="3"><label class="texto"><?php echo number_format($datos[6],0,',','.')?></label></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;"><label class="texto">Total $:</label></td>
  <td class="borde" colspan="3"><label class="texto"><?php echo number_format($datos[7],0,',','.')?></label></td>
</tr>
<tr>
  <td class="borde" colspan="4" style="text-align:center;"><div style="height:3px"></div></td>
</tr>
<tr>
  <td class="borde" colspan="4" style="text-align:center;"><input type="button" name="btn_Cancelar" id="btn_Cancelar" value="Cerrar Ventana" onclick="Cerrar();" /></td>
</tr>
<tr>
  <td class="borde" colspan="4" style="text-align:center;"><div style="height:3px"></div></td>
</tr>
</table>
</form>
 </div>
 <div id="close">
    	<div class="righty"></div>
    	<div class="lefty"></div>
 </div>
</div>
</body>
</html>